package com.admission.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import com.admission.dao.MessageReplyDao;
import com.admission.model.MessageReply;
@Repository
@Transactional
public class MessageReplyManager {
	private MessageReplyDao messageReplyDao;
	
	
	/**
	 * 通过id找唯一对象，无返回null
	 * 
	 * @param id
	 * @return
	 */
	public MessageReply getById(String id) {
		return messageReplyDao.findUniqueBy("id", id);
	}
	
	
	
    /**
     * 保存
     * 
     * @param Entity
     * throws Exception
     */
	public void save(MessageReply entity){
	        messageReplyDao.save(entity);
		}

	
	/**
	 * 通过留言id  批量删除
	 * 逗号隔开id
	 * @return
	 */
	public void deleteByMessId(String id){
		List<MessageReply> l=messageReplyDao.findBy("message.id",id);
		for(MessageReply mr:l){
			messageReplyDao.delete(mr);
		}
	}
	
	@Autowired
	public void setMessageRelyDao(MessageReplyDao messageRelyDao) {
		this.messageReplyDao = messageRelyDao;
	}
}
